﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.quest.Display {
    import flash.display.*;
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import org.aswing.geom.*;
    import Display.*;
    import flash.text.*;
    import org.aswing.event.*;
    import Display.aswingui.*;

    public class QuestCompleteView extends QuestPopupView {

        private static const HINT_TEXT_WIDTH:int = 310;
        private static const HINT_PANEL_HEIGHT:int = 100;
        private static const HINT_PANEL_GAP:int = 20;

        protected var m_rewardInfo:Array;
        protected var m_rewardIcon:DisplayObject;
        protected var m_rewardItemBG:DisplayObject;

        public function QuestCompleteView(_arg1:Dictionary, _arg2:Object){
            super(_arg1, _arg2);
        }
        override protected function init():void{
            m_npcIcon = m_assetDict["npcIcon"];
            m_bgAsset = m_assetDict["completedBG"];
            this.m_rewardInfo = m_assetDict["rewardInfo"];
            this.m_rewardIcon = m_assetDict["rewardIcon"];
            this.m_rewardItemBG = m_assetDict["rewardItemBG"];
            m_locObjects = m_assetDict["locObjects"];
            this.makeCenterPanel();
            this.makeBackground();
            ASwingHelper.prepare(this);
        }
        override protected function makeBackground():void{
            var _local1:MarginBackground = new MarginBackground(m_bgAsset, new Insets(0, 0, 20));
            this.setBackgroundDecorator(_local1);
        }
        private function makeRewards():void{
            var _local13:JPanel;
            var _local14:JPanel;
            var _local15:MarginBackground;
            var _local16:JPanel;
            var _local17:DisplayObject;
            var _local18:AssetPane;
            var _local19:JPanel;
            var _local20:AssetPane;
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
            _local1.append(ASwingHelper.horizontalStrut(15));
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.BOTTOM);
            var _local3:AssetPane = new AssetPane(m_npcIcon);
            _local2.append(_local3);
            _local1.append(_local2);
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.BOTTOM, -2);
            _local4.append(ASwingHelper.verticalStrut(15));
            var _local5:TextFormat = new TextFormat();
            _local5.align = TextFormatAlign.LEFT;
            var _local6:String = ZLoc.t("Quest", "complete_text");
            var _local7:JTextField = ASwingHelper.makeTextField(_local6, EmbeddedArt.TITLE_FONT, 18, 2925509, 0, _local5);
            TextFieldUtil.formatSmallCaps(_local7.getTextField(), new TextFormat(EmbeddedArt.TITLE_FONT, 24));
            var _local8:String = ZLoc.t("Quest", "rewards_text");
            var _local9:Number = TextFieldUtil.getLocaleFontSize(14, 12, null);
            var _local10:JTextField = ASwingHelper.makeTextField(_local8, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, _local9, 2925509);
            _local4.append(_local7);
            _local4.append(_local10);
            ASwingHelper.setEasyBorder(_local10, 0, 10);
            var _local11:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER, 5);
            ASwingHelper.setEasyBorder(_local11, 0, 30);
            var _local12:int;
            while (_local12 < this.m_rewardInfo.length) {
                _local13 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                _local14 = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.LEFT);
                this.m_rewardItemBG.scaleX = 0.9;
                this.m_rewardItemBG.scaleY = 0.9;
                _local15 = new MarginBackground(this.m_rewardItemBG);
                _local14.setBackgroundDecorator(_local15);
                _local14.setPreferredSize(new IntDimension(this.m_rewardItemBG.width, this.m_rewardItemBG.height));
                _local14.setMinimumSize(new IntDimension(this.m_rewardItemBG.width, this.m_rewardItemBG.height));
                _local14.setMaximumSize(new IntDimension(this.m_rewardItemBG.width, this.m_rewardItemBG.height));
                _local16 = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.BOTTOM, -32);
                _local17 = this.m_rewardInfo[_local12].image.content;
                _local18 = new AssetPane(_local17);
                _local19 = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
                _local19.append(_local18);
                _local14.append(ASwingHelper.horizontalStrut(((this.m_rewardItemBG.width - _local17.width) / 2)));
                _local14.append(_local19);
                _local16.append(_local14);
                _local20 = ASwingHelper.makeMultilineText((this.m_rewardInfo[_local12].text + " "), 200, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 20, 8085579);
                _local20.setVerticalAlignment(JLabel.CENTER);
                _local14.append(_local20);
                _local13.append(_local16);
                _local13.append(_local20);
                _local11.append(_local13);
                _local12++;
            };
            _local4.append(_local11);
            _local4.append(ASwingHelper.verticalStrut(13));
            _local1.append(ASwingHelper.horizontalStrut(10));
            _local1.append(_local4);
            m_interiorHolder.append(_local1);
        }
        override protected function makeCenterPanel():void{
            m_interiorHolder = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            makeHeader(17);
            m_interiorHolder.append(ASwingHelper.verticalStrut(-5));
            this.makeRewards();
            this.makeHintandButton();
            ASwingHelper.prepare(m_interiorHolder);
            this.append(m_interiorHolder);
            ASwingHelper.prepare(this);
        }
        override protected function makeHintandButton():void{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.CENTER);
            _local2.setPreferredHeight(HINT_PANEL_HEIGHT);
            _local2.append(ASwingHelper.verticalStrut(5));
            var _local3:JPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 0));
            _local3.append(ASwingHelper.horizontalStrut(HINT_PANEL_GAP));
            var _local4:AssetPane = new AssetPane(this.m_rewardIcon);
            _local3.append(_local4);
            var _local5:AssetPane = ASwingHelper.makeMultilineText(ZLoc.t("Quest", (m_data.name + "_dialog_finish"), m_locObjects), HINT_TEXT_WIDTH, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, TextFormatAlign.LEFT, 18, 489375);
            _local3.append(_local5);
            _local2.append(ASwingHelper.verticalStrut(((HINT_PANEL_HEIGHT - _local3.getPreferredHeight()) / 2)));
            _local2.append(_local3);
            _local1.append(_local2);
            m_interiorHolder.append(_local1);
            var _local6:JPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
            var _local7:String = ZLoc.t("Quest", (m_data.name + "_dialog_share_btn_text"));
            if ((((_local7.indexOf("Cannot find string") == 0)) || ((_local7.length <= 0)))){
                _local7 = ZLoc.t("Dialogs", "ShareExperience");
            };
            var _local8:CustomButton = new CustomButton(_local7, null, "BigGreenButtonUI");
            _local8.addActionListener(this.shareAndClose, 0, true);
            _local6.appendAll(_local8);
            m_interiorHolder.append(_local6);
        }
        protected function shareAndClose(_arg1:AWEvent):void{
            countDialogViewAction("SHARE");
            Global.world.viralMgr.sendQuestCompleteFeed(Global.player, m_data.name, m_questTitle);
            closePanel(_arg1);
        }

    }
}//package Modules.quest.Display 
